#include <signal.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>

using namespace std;

static void sig_usr( int );

int main( int argc, char *argv[] )
{
	if( signal( SIGUSR1, sig_usr ) == SIG_ERR )
		perror( "can't catch SIGUSR1" );
	if( signal( SIGUSR2, sig_usr ) == SIG_ERR )
		perror( "can't catch SIGUSR2" );
	while( 1 )
		pause();
}

static void sig_usr( int signo )
{
	if( SIGUSR1 == signo )
		cout << "received SIGUSR1" << endl;
	else if( SIGUSR2 == signo )
		cout << "received SIGUSR2" << endl;
	else
		printf( "received signal %d\n", signo );  // in APUE : err_dump(......)
}

